﻿<%--
///////////////////////////////////////////////////////////////////////////
/// File: <FileName>
/// Description: 
///    <Description>
/// Copyright© <DateTime.Now.Year> <Copyright>
/// History:
///     <DateTime.Now>    My.GenCode    Original Version
///////////////////////////////////////////////////////////////////////////
--%>
<%@Page Language="C#" Inherits="<NameSpace>.Web.BasePage" AutoEventWireup="false" %>
<%@import namespace="System" %>
<%@import namespace="System.Collections.Generic" %>
<%@import namespace="<<NameSpace>>.Domain.Entities" %>
<%@import namespace="<<NameSpace>>.Domain.Interfaces" %>
<%@import namespace="<<NameSpace>>.Business.Security" %>
<%@import namespace="<<NameSpace>>.Web.Controllers" %>
<script runat="server">
</script>
<%
    <<HandlerClassName>> _this = new <<HandlerClassName>>(this);
    <<EntityClassName>> _info = _this.<<ReadDetailMethodName>>();
    
    // 
    if( null==_info )
    {
        Response.Write( "<p>没有找到您要找的内容</p>" );
    }
    else
    {
        if (this.IsMaintainMode){
%>
        <h1 id="BtnEdit<<EntityName>>" class="hd">编辑</h1><%} %>
        <div id="<<EntityName>>Detail">[loop<<ContentItemsCodeBlock>>]
            <div>
                [<<Name>>]:<%=_info.<<Name>> %>
            </div>[/loop<<ContentItemsCodeBlock>>]
        </div>
<%  
        if (this.IsMaintainMode){
%>     
        <form id="Frm<<UpdateMethodName>>" method="post" action="<%=this.RootUrl %>/Ajax.aspx?op=<<UpdateMethodName>>">
            <div class="hiddenForm bd">
                <input type="hidden" name="Id" value="<%=_info.Id %>" />
                <ul>[loop<<FormItemsCodeBlock>>]
                    <li>
                        <label><<Name>>:</label><input type="text" name="<<Name>>" value="<%=_info.<<Name>> %>" />
                    </li>[/loop<<FormItemsCodeBlock>>]
                    <li>
                        <label>&nbsp;</label><button>修改</button>
                    </li>
                </ul>
            </div>
        </form>
        
        <script type="text/javascript">
        $(function(){
            var div = $("#<<EntityName>>Detail");
            var frm = $("#Frm<<UpdateMethodName>>");
            
            // 绑定提交表单         
            frm.ajaxSubmit( function(dat,fields){
                $('body').alert(dat.success||dat.failure||"")
                if( dat.success ){
                    // Do Something Here
                }
            });
            
            // 绑定编辑模式
            $("#BtnEdit<<EntityName>>").click(function(){
                EditMode(div,frm);
            });
        });
        
        function EditMode(divId,formId)
        {
            if('none'==$(divId).css('display')){
                $(divId).show();
                $(formId).hide();
            }
            else{
                $(divId).hide();
                $(formId).show();                
            }
                
        }
        </script>
<%
        }
    }
%>